home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer: Getting Started / Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin / pc / textfile / mac_faqs / lisp_faq / part1 next >
Encoding:
Internet Message Format  |  1995-01-01  |  60.3 KB

  1. Xref: bloom-picayune.mit.edu comp.lang.lisp:8749 news.answers:4559
  2. Path: bloom-picayune.mit.edu!enterpoop.mit.edu!spool.mu.edu!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!mkant
  3. From: mkant+@cs.cmu.edu (Mark Kantrowitz)
  4. Newsgroups: comp.lang.lisp,news.answers
  5. Subject: FAQ: Lisp Frequently Asked Questions 1/6 [Monthly posting]
  6. Summary: Introductory Matter and Bibliography of Introductions and References
  7. Message-ID: <lisp-faq-1.text_724237235@cs.cmu.edu>
  8. Date: 13 Dec 92 09:01:07 GMT
  9. Article-I.D.: cs.lisp-faq-1.text_724237235
  10. Expires: Tue, 26 Jan 1993 09:00:35 GMT
  11. Sender: news@cs.cmu.edu (Usenet News System)
  12. Reply-To: lisp-faq@think.com
  13. Followup-To: poster
  14. Organization: School of Computer Science, Carnegie Mellon
  15. Lines: 1231
  16. Approved: news-answers-request@MIT.Edu
  17. Supersedes: <lisp-faq-1.text_721645282@cs.cmu.edu>
  18. Nntp-Posting-Host: a.gp.cs.cmu.edu
  19.  
  20. Archive-name: lisp-faq/part1
  21. Last-Modified: Thu Nov  5 19:30:40 1992 by Mark Kantrowitz
  22. Version: 1.27
  23.  
  24. ;;; ****************************************************************
  25. ;;; Answers to Frequently Asked Questions about Lisp ***************
  26. ;;; ****************************************************************
  27. ;;; Written by Mark Kantrowitz and Barry Margolin
  28. ;;; lisp-faq-1.text -- 60654 bytes
  29.  
  30. This post contains Part 1 of the Lisp FAQ.
  31.  
  32. If you think of questions that are appropriate for this FAQ, or would
  33. like to improve an answer, please send email to us at lisp-faq@think.com.
  34.  
  35. Note that the lisp-faq mailing list is for discussion of the content
  36. of the FAQ posting only.  It is not the place to ask questions about Lisp;
  37. use either the common-lisp@ai.sri.com mailing list or the
  38. comp.lang.lisp newsgroup for that.  If a question appears frequently
  39. in one of those forums, it will get added to the FAQ list.
  40.  
  41. There are currently six parts to the Lisp FAQ:
  42.    1. Introductory Matter and Bibliography of Introductions and References
  43.    2. General Questions
  44.    3. Common Programming Pitfalls
  45.    4. Lisp/Scheme Implementations and Mailing Lists
  46.    5. CLOS and PCL Questions
  47.    6. FTP Archives and Resources
  48. All parts are posted to comp.lang.lisp. Part 4 is cross-posted to the
  49. comp.lang.scheme newsgroup. Part 5 is cross-posted to the
  50. comp.lang.clos newsgroup. 
  51.  
  52. Topics Covered (Part 1):
  53.  
  54.   [1-0]   What is the purpose of this newsgroup?
  55.   [1-1]   What documentation is available on Lisp? How can I learn Lisp?
  56.   [1-2]   How can I improve my Lisp programming style and coding efficiency?
  57.   [1-3]   Where can I learn about implementing Lisp interpreters and compilers?
  58.   [1-4]   What does CLOS, PCL, X3J13, CAR, CDR, ... mean? 
  59.   [1-5]   Where can I get a copy of the draft ANSI standard for Common Lisp?
  60.   [1-6]   Lisp Job Postings
  61.  
  62. Topics Covered (Part 2):
  63.  
  64.   [2-1]   Is there a GNU-Emacs interface to Lisp?
  65.   [2-3]   What is the equivalent of EXPLODE and IMPLODE in Common Lisp?
  66.   [2-4]   Is Lisp inherently slower than more conventional languages such as C?
  67.   [2-5]   Why does Common Lisp have "#'"?
  68.   [2-6]   How do I call non-Lisp functions from Lisp?
  69.   [2-7]   Can I call Lisp functions from other languages?
  70.   [2-8]   I want to call a function in a package that might not exist at
  71.           compile time. How do I do this?  
  72.   [2-9]   What is CDR-coding?
  73.   [2-10]  What is garbage collection?
  74.   [2-11]  How do I save an executable image of my loaded Lisp system?
  75.           How do I run a Unix command in my Lisp?
  76.           How do I get the current directory name from within a Lisp program?
  77.   [2-12]  I'm porting some code from a Symbolics Lisp machine to some
  78.           other platform, and there are strange characters in the code.
  79.           What do they mean?  
  80.   [2-13]  History: Where did Lisp come from?
  81.   [2-14]  How do I find the argument list of a function?
  82.           How do I get the function name from a function object?
  83.   [2-15]  How can I have two Lisp processes communicate via unix sockets?
  84.  
  85. Common Pitfalls (Part 3):
  86.  
  87.   [3-0]  Why does (READ-FROM-STRING "foobar" :START 3) return FOOBAR
  88.          instead of BAR?  
  89.   [3-1]  Why can't it deduce from (READ-FROM-STRING "foobar" :START 3)
  90.          that the intent is to specify the START keyword parameter
  91.          rather than the EOF-ERROR-P and EOF-VALUE optional parameters?   
  92.   [3-2]  Why can't I apply #'AND and #'OR?
  93.   [3-3]  I used a destructive function (e.g. DELETE, SORT), but it
  94.          didn't seem to work.  Why? 
  95.   [3-4]  After I NREVERSE a list, it's only one element long.  After I
  96.          SORT a list, it's missing things.  What happened? 
  97.   [3-5]  Why does (READ-LINE) return "" immediately instead of waiting
  98.          for me to type a line?  
  99.   [3-6]  I typed a form to the read-eval-print loop, but nothing happened. Why?
  100.   [3-7]  DEFMACRO doesn't seem to work.
  101.          When I compile my file, LISP warns me that my macros are undefined
  102.          functions, or complains "Attempt to call <function> which is 
  103.          defined as a macro.
  104.   [3-8]  Name conflict errors are driving me crazy! (EXPORT, packages)
  105.   [3-9]  Closures don't seem to work properly when referring to the
  106.          iteration variable in DOLIST, DOTIMES and DO.
  107.   [3-10] What is the difference between FUNCALL and APPLY?
  108.   [3-11] Miscellaneous things to consider when debugging code.
  109.   [3-12] When is it right to use EVAL?
  110.   [3-13] Why does my program's behavior change each time I use it?
  111.   [3-14] When producing formatted output in Lisp, where should you put the
  112.          newlines (e.g., before or after the line, FRESH-LINE vs TERPRI,
  113.          ~& vs ~% in FORMAT)?
  114.   [3-15] I'm using DO to do some iteration, but it doesn't terminate. 
  115.  
  116. Lisp/Scheme Implementations and Mailing Lists (Part 4):
  117.  
  118.   [4-0]   Free Lisp implementations.
  119.   [4-1]   Commercial Lisp implementations.
  120.   [4-2]   Free Scheme implementations.
  121.   [4-3]   Commercial Scheme implementations.
  122.   [4-4]   Other Commercial Lisp-like Language implementations.
  123.   [4-5]   Where can I get an implementation of Prolog in Lisp?
  124.   [4-6]   What is Dylan?
  125.   [4-7]   What Lisp-related discussion groups and mailing lists exist?
  126.   [4-8]   What are R4RS and IEEE P1178?
  127.   [4-9]   How do I do object-oriented programming in Scheme?
  128.  
  129. CLOS Questions (Part 5):
  130.  
  131.   [5-0]   What is CLOS (PCL) and where can I get it?
  132.           How do you pronounce CLOS?
  133.   [5-1]   What documentation is available about object-oriented
  134.           programming in Lisp?  
  135.   [5-2]   How I write a function that can access defstruct slots by
  136.           name?  I would like to write something like 
  137.           (STRUCTURE-SLOT <object> '<slot-name>).   
  138.   [5-3]   How can I list all the CLOS instances in a class?
  139.   [5-4]   How can I store data and CLOS instances (with possibly circular
  140.           references) on disk so that they may be retrieved at some later
  141.           time?
  142.   [5-5]   Given the name of a class, how can I get the names of its slots?
  143.  
  144. FTP Resources (Part 6):
  145.  
  146.   [6-0] General information about FTP Resources for Lisp and Scheme
  147.   [6-1] Repositories of Lisp Software
  148.   [6-2] Repositories of Scheme Software
  149.   [6-3] Publicly Redistributable Lisp Software
  150.   [6-4] Publicly Redistributable Scheme Software
  151.   [6-5] How can I use the X Window System or other GUIs from Lisp?
  152.   [6-6] Formatting code in LaTeX
  153.  
  154. Search for [#] to get to question number # quickly.
  155.  
  156.  
  157. Introduction:
  158.  
  159. Certain questions and topics come up frequently in the various network
  160. discussion groups devoted to and related to Lisp.  This file/article is
  161. an attempt to gather these questions and their answers into a convenient
  162. reference for Lisp programmers.  It (or a reference to it) is posted
  163. periodically.  The hope is that this will cut down on the user time and
  164. network bandwidth used to post, read and respond to the same questions
  165. over and over, as well as providing education by answering questions
  166. some readers may not even have thought to ask.
  167.  
  168. This is not a Lisp tutorial, nor is it an exhaustive list of all Lisp
  169. intricacies.  Lisp is a very powerful and expressive language, but with
  170. that power comes many complexities.  This list attempts to address the
  171. ones that average Lisp programmers are likely to encounter.  If you are
  172. new to Lisp, see the answer to the question "How can I learn Lisp?".
  173.  
  174. The latest version of this file is available via anonymous FTP from CMU
  175. and Thinking Machines: 
  176.  
  177.    To obtain the files from CMU, connect by anonymous ftp to any CMU CS
  178.    machine (e.g., ftp.cs.cmu.edu [128.2.206.173]), using username
  179.    "anonymous" and password "name@host". The files lisp-faq-1.text,
  180.    lisp-faq-2.text, lisp-faq-3.text, lisp-faq-4.text, lisp-faq-5.text
  181.    and lisp-faq-6.text are located in the directory
  182.        /afs/cs.cmu.edu/user/mkant/Public/Lisp-Utilities/
  183.    [Note: You must cd to this directory in one atomic operation, as
  184.    some of the superior directories on the path are protected from
  185.    access by anonymous ftp.] If your site runs the Andrew File System,
  186.    you can just cp the files directly without bothering with FTP.
  187.  
  188.    To obtain the files from Thinking Machines, ftp them from ftp.think.com,
  189.    in the directory /public/think/lisp/. The file faq.text contains all the
  190.    parts of the FAQ in one file. In addition, specific versions of the FAQ
  191.    are available as faq-<version>.text.
  192.  
  193. Unless otherwise specified, the Lisp dialect referred to is Common Lisp,
  194. as defined by "Common Lisp: the Language" (aka "CLtL1") as well as
  195. corrections (but not enhancements) from "Common Lisp: the Language, 2nd
  196. Edition" (aka "CLtL2"), both by Guy L. Steele, Jr. and published by
  197. Digital Press. Note that CLtL2 is NOT an official specification for
  198. the language; ANSI Committee X3J13 is preparing such a specification.
  199. See question [1-5] for information on the status of the ANSI
  200. specification for Common Lisp. Enhancements such as CLOS, conditions,
  201. and the LOOP macro will be referred to separately.
  202.  
  203. ----------------------------------------------------------------
  204. [1-0] What is the purpose of this newsgroup?
  205.  
  206. The newsgroup comp.lang.lisp exists for general discussion of
  207. topics related to the programming language Lisp. For example, possible
  208. topics can include (but are not necessarily limited to):
  209.    announcements of Lisp books and products
  210.    discussion of programs and utilities written in Lisp
  211.    discussion of portability issues
  212.    questions about possible bugs in Lisp implementations
  213.    problems porting an implementation to some architecture
  214. Postings should be of general interest to the Lisp community. See also
  215. question [4-7].
  216.  
  217. Questions about object oriented programming in Lisp should be directed
  218. to the newsgroup comp.lang.clos. Similarly, questions about the
  219. programming language Scheme should be directed to the newsgroup
  220. comp.lang.scheme. Discussion of functional programming language issues
  221. should be directed to the newsgroup comp.lang.functional. Discussion
  222. of AI programs implemented in Lisp should sometimes be cross-posted to
  223. the newsgroup comp.ai.
  224.  
  225. ----------------------------------------------------------------
  226. [1-1] What documentation is available on Lisp? 
  227.       How can I learn Lisp?
  228.  
  229. There are several good Lisp introductions and tutorials:
  230.  
  231.    1. David S. Touretzky
  232.       "Common Lisp: A Gentle Introduction to Symbolic Computation"
  233.       Benjamin/Cummings Publishers, 1990. 384 pages.
  234.            Perhaps the best tutorial introduction to the language. It has
  235.            clear and correct explanations, and covers some fairly advanced
  236.            topics. The book is an updated Common Lisp version of the 1984
  237.            edition published by Harper and Row Publishers. 
  238.  
  239.            Three free Lisp educational tools which were used in the book --
  240.            Evaltrace, DTRACE and SDRAW -- are available by anonymous ftp from
  241.            b.gp.cs.cmu.edu:/usr/dst/public/{lisp,evaltrace}. Evaltrace is a
  242.            graphical notation for explaining how evaluation works and is
  243.            described in "Visualizing Evaluation in Applicative Languages" by
  244.            David S.  Touretzky and Peter Lee, CACM 45-59, October 1992. DTRACE
  245.            is a "detailed trace" which provides more information than the 
  246.            tracing tools provided with most Common Lisp implementations. SDRAW
  247.            is a program that draws cons cell structures both for X11 and ascii
  248.            terminals.
  249.  
  250.    2. Robert Wilensky
  251.       "Common LISPcraft"
  252.       W. W. Norton, 1986. 385 pages.
  253.  
  254.    3. Wade L. Hennessey 
  255.       "Common Lisp"
  256.       McGraw-Hill, 1989. 395 pages.
  257.            Fairly good, but jumps back and forth from the simple to the
  258.            complex rather quickly, with no clear progression in difficulty.
  259.  
  260.    4. Laurent Siklossy
  261.       "Let's Talk LISP"
  262.       Prentice-Hall, NJ, 1976. 237 pages.
  263.            Good introduction, but quite out of date.
  264.  
  265.    5. Stuart C. Shapiro
  266.       "Common Lisp: An Interactive Approach"
  267.       Computer Science Press/W.H. Freeman, New York, 1992.
  268.       ISBN 0-7167-8218-9
  269.  
  270. Other introductions to Lisp include:
  271.  
  272.    1. A. A. Berk.
  273.       "LISP, The Language of Artificial Intelligence"
  274.       Van Nostrand Reinhold, 1985. 160 pages.
  275.  
  276.    2. Paul Y. Gloess.
  277.       "An Alfred handy guide to Understanding LISP"
  278.       Alfred Publishers (Sherman Oaks, CA), 1982. 64 pages.
  279.  
  280.    3. Ward D. Maurer.
  281.       "The Programmer's Introduction to LISP"
  282.       American Elsevier, 1972. 112 pages.
  283.  
  284.    4. Hank Bromley and Richard Lamson.
  285.       "LISP Lore: A Guide to Programming the LISP Machine"
  286.       Kluwer Academic (Boston), 1987. 337 pages.
  287.  
  288.    5. Sharam Hekmatpour.
  289.       "Introduction to LISP and Symbol Manipulation"
  290.       Prentice Hall (New York), 1988. 303 pages.
  291.  
  292.    6. Deborah G. Tatar
  293.       "A programmer's guide to Common Lisp"
  294.       Digital Press, 1987. 327 pages. ISBN 0-932376-87-8.
  295.            Good introduction on Common Lisp.
  296.  
  297.    7. Timothy Koschmann
  298.       "The Common Lisp Companion"
  299.       John Wiley & Sons, 1990.
  300.        Targeted for those with some programming experience who wish to 
  301.        learn draft-ANSI Common Lisp, including CLOS and the CL condition 
  302.        system. Examples progress incrementally from simple numerical 
  303.        calculation all the way to a logic-programming extension to CL.
  304.   
  305. More advanced introductions to Lisp and its use in Artificial
  306. Intelligence include:
  307.  
  308.    1. Peter Norvig.
  309.       "Paradigms of AI Programming: Case Studies in Common Lisp"
  310.       Morgan Kaufmann, 1992. 946 pages. ISBN 1-55860-191-0.
  311.  
  312.         Provides an in-depth exposition of advanced AI programming techniques
  313.         and includes large-scale detailed examples. The book is the most
  314.         advanced AI/Common-Lisp programming text and reference currently
  315.         available, and hence is not for the complete novice.  It focuses on the
  316.         programming techniques necessary for building large AI systems,
  317.         including object-oriented programming, and has a strong performance
  318.         orientation.
  319.  
  320.         The text is marked by its use of "non-toy" examples to illustrate the
  321.         techniques. All of the examples are written in Common Lisp, and copies
  322.         of the source code are available by anonymous ftp from
  323.         unix.sri.com:pub/norvig and on disk in Macintosh or DOS format from
  324.         the publisher. Some of the techniques described include rule-based
  325.         pattern matching (GPS, Eliza, a subset of Macsyma, the Emycin expert
  326.         system shell), constraint propagation and backtracking (Waltz
  327.         line-labelling), alpha-beta search (Othello), natural language
  328.         processing (top-down, bottom-up and chart parsing), logic-programming
  329.         (unification and Prolog), interpreters and compilers for Scheme, and
  330.         object-oriented programming (CLOS).
  331.  
  332.         The examples are also used to illustrate good programming style and
  333.         efficiency. There is a guide to trouble-shooting and debugging Lisp
  334.         programs, a style guide, and a discussion of portability problems.
  335.         Some of the efficiency techniques described include memoization,
  336.         data indexing, compilation, delaying computation, proper use of
  337.         declarations, avoiding garbage collection, and choosing and using the
  338.         correct data structure.
  339.  
  340.         The book also serves as an advanced introduction to Common Lisp, with
  341.         sections on the Loop macro, CLOS and sequences, and some coverage of 
  342.         error handling, series, and the package facility.
  343.  
  344.    2. Eugene Charniak, Christopher K. Riesbeck, Drew V. McDermott
  345.       and James R. Meehan.
  346.       "Artificial Intelligence Programming", 2nd edition.
  347.       Lawrence Erlbaum Associates (Hillsdale, NJ), 1987. 533 pages.
  348.            Provides many nice code fragments, all of which are written
  349.            in Common Lisp. The first half of the book covers topics
  350.            like macros, the reader, data structures, control structures,
  351.            and defstructs. The second half of the book describes
  352.            programming techniques specific to AI, such as
  353.            discrimination nets, production systems, deductive database
  354.            retrieval, logic programming, and truth maintenance.
  355.  
  356.    3. Patrick H. Winston and Berthold K. P. Horn.
  357.       "LISP", 3rd edition.
  358.       Addison-Wesley (Reading, MA), 1989. 611 pages. ISBN 0-201-08319-1
  359.            Covers the basic concepts of the language, but also gives a lot
  360.            of detail about programming AI topics such as rule-based expert
  361.            systems, forward chaining, interpreting transition trees, 
  362.            compiling transition trees and finding patterns in images. Not 
  363.            a tutorial. Has many good examples.
  364.  
  365.    4. Rodney A. Brooks.
  366.       "Programming in Common Lisp"
  367.       Wiley, 1985. 303 pages.
  368.  
  369.    5. John R. Anderson, Albert T. Corbett, and Brian J. Reiser.
  370.       "Essential LISP"
  371.       Addison-Wesley (Reading, MA), 1987. 352 pages.
  372.            Concentrates on how to use Lisp with iteration and recursion.
  373.  
  374.    6. Robert D. Cameron and Anthony H. Dixon
  375.       "Symbolic Computing with Lisp"
  376.       Prentice-Hall, 1992, 326 pages. ISBN 0-13-877846-9.
  377.            The book is intended primarily as a third-year computer science
  378.            text. In terms of programming techniques, it emphasizes recursion
  379.            and induction, data abstraction, grammar-based definition of Lisp
  380.            data structures and functional programming style. It uses
  381.            two Lisp languages: 
  382.                 (1) a purely functional subset of Lisp called Small Lisp and
  383.                 (2) Common Lisp.
  384.            An MS-DOS interpreter for Small Lisp (including source) is
  385.            provided with the book.  It considers applications of Lisp
  386.            to formal symbolic data domains: algebraic expressions,
  387.            logical formulas, grammars and programming languages. 
  388.  
  389.    7. Hasemer and Domingue.
  390.       "Common Lisp Programming for Artificial Intelligence"
  391.       Addison-Wesley, 1989.
  392.  
  393.    8. Steven Tanimoto
  394.       "The Elements of Artificial Intelligence: An Introduction Using Lisp"
  395.       Computer Science Press, Rockville, MD, 1987, 530 pages.
  396.  
  397.    9. Patrick R. Harrison
  398.       "Common Lisp and Artificial Intelligence"
  399.       Prentice Hall, 1990. ISBN 0-13-155243
  400.  
  401.   10. Rajeev Sangal
  402.       "Programming Paradigms in Lisp"
  403.       McGraw-Hill, 1991. ISBN 0-07-054666-5.
  404.  
  405. General Lisp reference books include:
  406.  
  407.    1. Guy L. Steele
  408.       "Common Lisp: The Language" [CLtL1]
  409.       Digital Press, 1984. 465 pages. ISBN 0-932376-41-X.
  410.  
  411.    2. Guy L. Steele
  412.       "Common Lisp: The Language, 2nd Edition" [CLtL2]
  413.       Digital Press, 1990. 1029 pages. ISBN 1-55558-041-6.
  414.  
  415.    3. Franz Inc. 
  416.       "Common Lisp: The Reference"
  417.       Addison-Wesley, Reading, MA 1988. ISBN 0-201-11458-5
  418.            Entries on lisp functions in alphabetical order.
  419.  
  420.    4. K. Dybvig. 
  421.       "The Scheme programming language"
  422.       Prentice Hall, 1987.
  423.          Good reference for Scheme.
  424.  
  425. Lisp periodicals include:
  426.         
  427.    1. LISP Pointers.
  428.       Published by ACM SIGPLAN six times a year. Volume 1, Number 1
  429.       was April-May 1987. 
  430.  
  431.    2. LISP and Symbolic Computation, Kluwer Academic Press. Volume 1
  432.       was published in 1989. (jlz@lucid.com is the editor).  ISSN 0892-4635.
  433.       Subscriptions: Institutions $169; Individuals $80. Add $8 for
  434.       air mail. Kluwer Academic Publishers, PO Box 322, 3300 AH Dordrecht, 
  435.       The Netherlands, or Kluwer Academic Publishers, PO Box 358, Accord
  436.       Station, Hingham, MA 02018-0358. 
  437.  
  438.    3. Proceedings of the biannual ACM Lisp and Functional Programming
  439.       Conference. (First one was in 1980.)
  440.  
  441.    4. Proceedings of the annual Lisp Users and Vendors Conference.
  442.  
  443. Implementation-specific questions:
  444.  
  445.    1. Lucid. See the wizards.doc file that comes with the Lucid
  446.    release. It describes functions, macros, variables and constants that
  447.    are not official parts of the product and are not supported.
  448.    Constructs described in this file include: the interrupt facility, the
  449.    source file recording facility, the resource facility, multitasking,
  450.    writing your own streams, lisp pipes, i/o buffers, the compiler,
  451.    floating-point functions, memory management, debugger information, the
  452.    window tool kit, extensions to the editor, the foreign function
  453.    interface, clos information, delivery toolkit information, and Lucid
  454.    lisp training classes. The wizards.doc file also covers i/o
  455.    constructs, functions for dealing with DEFSTRUCT, functions and
  456.    constants for dealing with procedure objects, functions and constants
  457.    for dealing with code objects, function for mapping objects,
  458.    additional keyword argument to DISKSAVE, function used in the
  459.    implementation of arrays, function for monitor-specific behavior for a
  460.    process, additional keyword argument to RUN-PROGRAM, and load-time
  461.    evaluation.
  462.  
  463. Introductions to Scheme (Many books on Scheme are worth reading
  464. even if you use Common Lisp, because many of the issues are similar):
  465.  
  466.    1. Harold Abelson and Gerald Jay Sussman, with Julie Sussman.
  467.       "Structure and Interpretation of Computer Programs"
  468.       MIT Press (Cambridge, MA) and McGraw-Hill (New York), 1985.
  469.       542 pages. ISBN 0-262-01077-1
  470.            Starts off introductory, but rapidly gets into powerful
  471.            Lisp-particular constructs, such as using closures and
  472.            engines, building interpreters, compilers and
  473.            object-oriented systems.  
  474.  
  475.    2. Daniel P. Friedman and M. Felleisen.
  476.       "The Little LISPer"
  477.       MIT Press (Cambridge, MA), 3rd printing, 1989. ISBN 0-262-56038-0.
  478.       Science Research Associates (Chicago), 3rd ed, 1989. 206 pages.
  479.            Good for a quick introduction. Uses Scheme instead of
  480.            Common Lisp.  (The book uses a dialect of Scheme with
  481.            footnotes about translating to Scheme or Common Lisp. The
  482.            footnotes won't allow a non-expert to use Common Lisp for
  483.            the advanced chapters because of the complexity.)
  484.  
  485.    3. George Springer and Daniel P. Friedman
  486.       "Scheme and the Art of Programming" 
  487.       MIT Press and McGraw Hill, 1990, 596 pages.
  488.            Introduces basic concepts of programming in Scheme. Also deals 
  489.            with object oriented programming, co-routining, continuations. 
  490.            Gives numerous examples.
  491.  
  492.    4. Wolfgang Kreutzer and Bruce McKenzie
  493.       "Programming for Artificial Intelligence: 
  494.        Methods, Tools and Applications"
  495.       Addison-Wesley (Reading, MA), 1990. 682 pages. 
  496.       ISBN 0-201-41621-2.
  497.            Discusses Scheme, Prolog, and Smalltalk, gives an overview of
  498.            the history and philosophy of AI, surveys three major
  499.            programming paradigms (procedural, declarative, and
  500.            object-oriented), and metaphors to AI programming.
  501.  
  502.    5. Smith
  503.       "Introduction to Scheme"
  504.        1988.
  505.            Focuses on PC Scheme.
  506.  
  507.    6. Michael Eisenberg 
  508.       "Programming in Scheme"
  509.       Scientific Press (Redwood City, CA), 1988. 304 pages.
  510.  
  511.    7. The Ken Dickey article, "The Scheme Programming Language", in
  512.       COMPUTER LANGUAGES magazine, and the Revised^4 Report on the
  513.       Algorithmic Language Scheme, both of which are available by anonymous
  514.       ftp from the scheme archive at nexus.yorku.ca.
  515.  
  516.    8. Two articles in BYTE Magazine, February 1988, by Abelson and
  517.       Sussman, and Clinger.
  518.  
  519.    9. The Info files from the MIT Scheme implementation.
  520.  
  521. Special Topics:
  522.  
  523.    Garbage Collection:
  524.  
  525.       Wilson, Paul R., "Uniprocessor Garbage Collection Techniques"
  526.       Proceedings of the 1992 International Workshop on Memory Management.
  527.       Surveys garbage collection techniques. Available by anonymous ftp from
  528.       cs.utexas.edu:pub/garbage/gcsurvey.ps. Contact wilson@cs.utexas.edu
  529.       for more info.
  530.  
  531. ----------------------------------------------------------------
  532. [1-2] How can I improve my Lisp programming style and coding efficiency?
  533.  
  534. There are several books about Lisp programming style, including:
  535.    
  536.    1. Molly M. Miller and Eric Benson
  537.       "Lisp Style and Design"
  538.       Digital Press, 1990. 214 pages. ISBN 1-55558-044-0.
  539.            How to write large Lisp programs and improve Lisp programming 
  540.            style. Uses the development of Lucid CL as an example. 
  541.  
  542.    2. Robin Jones, Clive Maynard, and Ian Stewart.
  543.       "The Art of Lisp Programming"
  544.       Springer-Verlag, 1989. 169 pages.
  545.  
  546.    3. W. Richard Stark.
  547.       "LISP, Lore, and Logic: an algebraic view of LISP
  548.        programming, foundations, and applications"
  549.       Springer-Verlag, 1990. 278 pages. ISBN 0-387-97072-X
  550.            Self-modifying code, self-reproducing programs, etc.
  551.  
  552.    4. CMU CL User's Manual, Chapter 7, (talks about writing
  553.       efficient code). It is available by anonymous ftp from any CMU CS 
  554.       machine (e.g., ftp.cs.cmu.edu [128.2.206.173]) as the file
  555.         /afs/cs.cmu.edu/project/clisp/docs/cmu-user/cmu-user.ps 
  556.       [when getting this file by anonymous ftp, one must cd to 
  557.       the directory in one atomic operation, as some of the superior
  558.       directories on the path are protected from access by anonymous ftp.]
  559.  
  560.    5. See also Norvig's book, SICP (Abelson & Sussman), SAP
  561.       (Springer and Friedman).
  562.  
  563.    6. Hallvard Tretteberg's Lisp Style Guide is available by anonymous
  564.       ftp in ftp.think.com:/public/think/lisp/style-guide.text. There is
  565.       a fair bit of overlap between Hallvard's style guide and the notes
  566.       below and in part 3 of this FAQ.
  567.  
  568. Here are some general suggestions/notes about improving Lisp
  569. programming style, readability, correctness and efficiency:
  570.  
  571.    General Programming Style Rules:
  572.  
  573.       - Write short functions, where each function provides a single,
  574.         well-defined operation. Small functions are easier to
  575.         read, write, test, debug, and understand.
  576.  
  577.       - Use descriptive variable and function names. If it isn't clear
  578.         from the name of a function or variable what its purpose is,
  579.         document it with a documentation string and a comment. In fact,
  580.         even if the purpose is evident from the name, it is still worth
  581.         documenting your code.
  582.  
  583.       - Don't write Pascal (or C) code in Lisp. Use the appropriate
  584.         predefined functions -- look in the index to CLtL2, or use the
  585.         APROPOS and DESCRIBE functions. Don't put a close parenthesis
  586.         on a line by itself -- this can really aggravate programmers
  587.         who grew up on Lisp. Lisp-oriented text editors include tools
  588.         for ensuring balanced parentheses and for moving across 
  589.         pairs of balanced parentheses.
  590.  
  591.       - Use proper indentation -- you should be able to understand
  592.         the structure of your definitions without noticing the parentheses. 
  593.  
  594.    The following functions often abused or misunderstood by novices. 
  595.    Think twice before using any of these functions.
  596.  
  597.       - EVAL. Novices almost always misuse EVAL. When experts use
  598.         EVAL, they often would be better off using APPLY, FUNCALL, or
  599.         SYMBOL-VALUE. Use of EVAL when defining a macro should set off
  600.         a warning bell -- macro definitions are already evaluated
  601.         during expansion. See also the answer to question 3-12.
  602.  
  603.       - PROGV. PROGV binds dynamic variables and is often misused in
  604.         conjunction with EVAL, which uses the dynamic environment. 
  605.         In general, avoid unnecessary use of special variables.
  606.         PROGV is mainly for writing interpreters for languages embedded
  607.         in Lisp. If you want to bind a list of values to a list of
  608.         lexical variables, use
  609.             (MULTIPLE-VALUE-BIND (..) (VALUES-LIST ..) ..)
  610.         or
  611.             (MULTIPLE-VALUE-SETQ (..) (VALUES-LIST ..))
  612.         instead. Most decent compilers can optimize this expression. 
  613.         However, use of this idiom is not to be encouraged unless absolutely
  614.         necessary.
  615.  
  616.       - CATCH and THROW. Often a named BLOCK and RETURN-FROM are
  617.         more appropriate. Use UNWIND-PROTECT when necessary.
  618.  
  619.       - Destructive operations, such as NCONC, SORT, DELETE,
  620.         RPLACA, and RPLACD, should be used carefully and sparingly.
  621.         In general, trust the garbage collector: allocate new
  622.         data structures when you need them.
  623.  
  624.    To improve the readability of your code,
  625.  
  626.       - Don't use any C{A,D}R functions with more than two
  627.         letters between the C and the R. When nested, they become
  628.         hard to read. If you have complex data structures, you
  629.         are often better off describing them with a DEFSTRUCT,
  630.         even if the type is LIST. If you must use C{A,D}R, try to
  631.         use destructuring-bind instead, or at least SECOND, THIRD,
  632.         NTH, NTHCDR, etc.
  633.  
  634.       - Use COND instead of IF and PROGN. In general, don't use PROGN if
  635.         there is a way to write the code within an implicit
  636.         PROGN. For example, 
  637.            (IF (FOO X)
  638.                (PROGN (PRINT "hi there") 23)
  639.                34)
  640.         should be written using COND instead.
  641.  
  642.       - Never use a 2-argument IF or a 3-argument IF with a second
  643.         argument of NIL unless you want to emphasize the return value;
  644.         use WHEN and UNLESS instead. You will want to emphasize the
  645.         return value when the IF clause is embedded within a SETQ,
  646.         such as (SETQ X (IF (EQ Y Z) 2 NIL)). If the second argument 
  647.         to IF is the same as the first, use OR instead: (OR P Q) rather
  648.         than (IF P P Q). Use UNLESS instead of (WHEN (NOT ..) ..)
  649.         but not instead of (WHEN (NULL ..) ..).
  650.  
  651.       - Use COND instead of nested IF statements. Be sure to check for
  652.         unreachable cases, and eliminate those cond-clauses.
  653.  
  654.       - Use backquote, rather than explicit calls to LIST, CONS, and
  655.         APPEND, whenever writing a form which produces a Lisp form, but
  656.         not as a general substitute for LIST, CONS and APPEND. LIST, 
  657.         CONS and APPEND usually allocate new storage, but lists produced
  658.         by backquote may involve destructive modification (e.g., ,.).
  659.  
  660.       - Make the names of special (global) variables begin and end
  661.         with an asterisk (*): (DEFVAR *GLOBAL-VARIABLE*)   
  662.         Some programmers will mark the beginning and end of an internal
  663.         global variable with a percent (%) or a period (.).
  664.         Make the names of constants begin and end with a plus (+):
  665.         (DEFCONSTANT +E+ 2.7182818)
  666.         This helps distinguish them from lexical variables. Some people
  667.         prefer to use macros to define constants, since this avoids
  668.         the problem of accidentally trying to bind a symbol declared
  669.         with defconstant.
  670.  
  671.       - If your program is built upon an underlying substrate which is
  672.         implementation-dependent, consider naming those functions and
  673.         macros in a way that visually identifies them, either by placing
  674.         them in their own package, or prepending a character like a %, ., 
  675.         or ! to the function name. Note that many programmers use the
  676.         $ as a macro character for slot access, so it should be avoided
  677.         unless you're using it for that purpose.
  678.  
  679.       - Don't use property lists. Instead, use an explicit hash table.
  680.         This helps avoid problems caused by the symbol being in the wrong
  681.         package, accidental reuse of property keys from other
  682.         programs, and allows you to customize the structure of the table. 
  683.  
  684.       - Use the most specific construct that does the job. This lets
  685.         readers of the code see what you intended when writing the code.
  686.         For example, don't use SETF if SETQ will do (e.g., for lexical
  687.         variables). Use the most specific predicate to test your conditions.
  688.         If you intend for a function to be a predicate, have it return T
  689.         for true, not just non-NIL. 
  690.  
  691.       - When NIL is used as an empty list, use () in your code. When NIL
  692.         is used as a boolean, use NIL. Similarly, use NULL to test for an
  693.         empty list, NOT to test a logical value. Use ENDP to test for the
  694.         end of a list, not NULL.
  695.  
  696.       - Don't use the &AUX lambda-list keyword. It is always clearer to
  697.         define local variables using LET or LET*.
  698.  
  699.       - When using RETURN and RETURN-FROM to exit from a block, don't
  700.         use (VALUES ..) when returning only one value, except if you
  701.         are using it to suppress extra multiple values from the first
  702.         argument. 
  703.  
  704.       - If you want a function to return no values (i.e., equivalent to
  705.         VOID in C), use (VALUES) to return zero values. This signals
  706.         to the reader that the function is used mainly for side-effects.
  707.  
  708.       - (VALUES (VALUES 1 2 3)) returns only the first value, 1.
  709.         You can use (VALUES (some-multiple-value-function ..)) to suppress
  710.         the extra multiple values from the function. Use MULTIPLE-VALUE-PROG1
  711.         instead of PROG1 when the multiple values are significant.
  712.  
  713.       - When using MULTIPLE-VALUE-BIND and DESTRUCTURING-BIND, don't rely
  714.         on the fact that NIL is used when values are missing. This is
  715.         an error in some implementations of DESTRUCTURING-BIND. Instead,
  716.         make sure that your function always returns the proper number of
  717.         values.
  718.  
  719.     Documentation:
  720.  
  721.       - Comment your code. Use three semicolons in the left margin before
  722.         the definition for major explanations. Use two semicolons that
  723.         float with the code to explain the routine that follows. Two
  724.         semicolons may also be used to explain the following line when the
  725.         comment is too long for the single semicolon treatment. Use
  726.         a single semicolon to the right of the code to explain a particular
  727.         line with a short comment. The number of semicolons used roughly
  728.         corresponds with the length of the comment. Put at least one blank
  729.         line before and after top-level expressions.
  730.  
  731.       - Include documentation strings in your code. This lets users
  732.         get help while running your program without having to resort to
  733.         the source code or printed documentation. 
  734.  
  735.    Issues related to macros:
  736.  
  737.       - Never use a macro instead of a function for efficiency reasons.
  738.         Declaim the function as inline -- for example, 
  739.           (DECLAIM (INLINE ..))
  740.         This is *not* a magic bullet -- be forewarned that inline
  741.         expansions can often increase the code size dramatically. INLINE
  742.         should be used only for short functions where the tradeoff is
  743.         likely to be worthwhile: inner loops, types that the compiler
  744.         might do something smart with, and so on.
  745.  
  746.       - When defining a macro that provides an implicit PROGN, use the
  747.         &BODY lambda-list keyword instead of &REST.
  748.  
  749.       - Use gensyms for bindings within a macro, unless the macro lets
  750.         the user explicitly specify the variable. For example:
  751.             (defmacro foo ((iter-var list) body-form &body body)
  752.               (let ((result (gensym "RESULT")))
  753.                 `(let ((,result nil))
  754.                    (dolist (,iter-var ,list ,result)
  755.                      (setq ,result ,body-form)
  756.                      (when ,result
  757.                         ,@body)))))        
  758.         This avoids errors caused by collisions during macro expansion
  759.         between variable names used in the macro definition and in the
  760.         supplied body.
  761.  
  762.       - Use a DO- prefix in the name of a macro that does some kind of
  763.         iteration, WITH- when the macro establishes bindings, and
  764.         DEFINE- or DEF- when the macro creates some definitions. Don't
  765.         use the prefix MAP- in macro names, only in function names.
  766.  
  767.       - Don't create a new iteration macro when an existing function
  768.         or macro will do.
  769.  
  770.       - Don't define a macro where a function definition will work just
  771.         as well -- remember, you can FUNCALL or MAPCAR a function but 
  772.         not a macro.
  773.  
  774.       - The LOOP and SERIES macros generate efficient code. If you're
  775.         writing a new iteration macro, consider learning to use one
  776.         of them instead.
  777.   
  778.    File Modularization:
  779.  
  780.       - If your program involves macros that are used in more than one
  781.     file, it is generally a good idea to put such macros in a separate
  782.     file that gets loaded before the other files. The same things applies
  783.     to primitive functions. If a macro is complicated, the code that
  784.     defines the macro should be put into a file by itself. In general, if
  785.     a set of definitions form a cohesive and "independent" whole, they
  786.     should be put in a file by themselves, and maybe even in their own
  787.     package. It isn't unusual for a large Lisp program to have files named
  788.     "site-dependent-code", "primitives.lisp", and "macros.lisp". If a file
  789.     contains primarily macros, put "-macros" in the name of the file.
  790.  
  791.    Stylistic preferences:
  792.  
  793.       - Use (SETF (CAR ..) ..) and (SETF (CDR ..) ..) in preference to
  794.         RPLACA and RPLACD. Likewise (SETF (GET ..) ..) instead of PUT.
  795.  
  796.       - Use INCF, DECF, PUSH and POP instead instead of the corresponding
  797.         SETF forms.
  798.  
  799.       - Many programmers religiously avoid using CATCH, THROW, BLOCK,
  800.         PROG, GO and TAGBODY.  Tags and go-forms should only be necessary
  801.         to create extremely unusual and complicated iteration constructs. In
  802.         almost every circumstance, a ready-made iteration construct or
  803.         recursive implementation is more appropriate.
  804.  
  805.       - Don't use LET* where LET will do. Don't use LABELS where FLET
  806.         will do. Don't use DO* where DO will do.
  807.  
  808.       - Don't use DO where DOTIMES or DOLIST will do.
  809.  
  810.       - If you like using MAPCAR instead of DO/DOLIST, use MAPC when
  811.         no result is needed -- it's more efficient, since it doesn't
  812.         cons up a list. If a single cumulative value is required, use
  813.         REDUCE. If you are seeking a particular element, use FIND,
  814.         POSITION, or MEMBER.
  815.  
  816.       - If using REMOVE and DELETE to filter a sequence, don't use the
  817.         :test-not keyword or the REMOVE-IF-NOT or DELETE-IF-NOT functions.
  818.         Use COMPLEMENT to complement the predicate and the REMOVE-IF
  819.         or DELETE-IF functions instead.
  820.  
  821.       - Use complex numbers to represent points in a plane.
  822.  
  823.       - Don't use lists where vectors are more appropriate. Accessing the
  824.         nth element of a vector is faster than finding the nth element
  825.         of a list, since the latter requires pointer chasing while the
  826.         former requires simple addition. Vectors also take up less space
  827.         than lists. Use adjustable vectors with fill-pointers to
  828.         implement a stack, instead of a list -- using a list continually
  829.         conses and then throws away the conses.
  830.  
  831.       - When adding an entry to an association list, use ACONS, not
  832.         two calls to CONS. This makes it clear that you're using an alist.
  833.  
  834.       - If your association list has more than about 10 entries in it,
  835.         consider using a hash table. Hash tables are often more efficient.
  836.  
  837.       - When you don't need the full power of CLOS, consider using
  838.         structures instead. They are often faster, take up less space, and
  839.         easier to use.
  840.  
  841.       - Use PRINT-UNREADABLE-OBJECT when writing a print-function.
  842.  
  843.       - Use WITH-OPEN-FILE instead of OPEN and CLOSE.
  844.  
  845.       - When a HANDLER-CASE clause is executed, the stack has already
  846.         unwound, so dynamic bindings that existed when the error
  847.         occured may no longer exist when the handler is run. Use
  848.         HANDLER-BIND if you need this. 
  849.  
  850.       - When using CASE and TYPECASE forms, if you intend for the form
  851.         to return NIL when all cases fail, include an explicit OTHERWISE
  852.         clause. If it would be an error to return NIL when all cases
  853.         fail, use ECASE, CCASE, ETYPECASE or CTYPECASE instead.
  854.  
  855.       - Use local variables in preference to global variables whenever
  856.         possible. Do not use global variables in lieu of parameter passing.
  857.         Global variables can be used in the following circumstances:
  858.           *  When one function needs to affect the operation of
  859.              another, but the second function isn't called by the first.
  860.              (For example, *load-pathname* and *break-on-warnings*.)
  861.           *  When a called function needs to affect the current or future
  862.              operation of the caller, but it doesn't make sense to accomplish
  863.              this by returning multiple values.
  864.           *  To provide hooks into the mechanisms of the program.
  865.              (For example, *evalhook*, *, /, and +.)
  866.           *  Parameters which, when their value is changed, represent a
  867.              major change to the program.
  868.              (For example, *print-level* and *print-readably*.)
  869.           *  For state that persists between invocations of the program.
  870.              Also, for state which is used by more than one major program.
  871.              (For example, *package*, *readtable*, *gensym-counter*.)
  872.           *  To provide convenient information to the user.
  873.              (For example, *version* and *features*.)
  874.           *  To provide customizable defaults. 
  875.              (For example, *default-pathname-defaults*.)
  876.           *  When a value affects major portions of a program, and passing
  877.              this value around would be extremely awkward. (The example
  878.              here is output and input streams for a program. Even when
  879.              the program passes the stream around as an argument, if you
  880.              want to redirect all output from the program to a different
  881.              stream, it is much easier to just rebind the global variable.)
  882.  
  883.    Correctness and efficiency issues:
  884.  
  885.       - In CLtL2, IN-PACKAGE does not evaluate its argument. Use defpackage
  886.         to define a package and declare the external (exported)
  887.         symbols from the package. 
  888.  
  889.       - The ARRAY-TOTAL-SIZE-LIMIT may be as small as 1024, and the
  890.         CALL-ARGUMENTS-LIMIT may be as small as 50. 
  891.  
  892.       - Novices often mistakenly quote the conditions of a CASE form.
  893.         For example, (case x ('a 3) ..) is incorrect. It would return
  894.         3 if x were the symbol QUOTE. Use (case x (a 3) ..) instead.
  895.  
  896.       - Avoid using APPLY to flatten lists. (apply #'append list-of-lists)
  897.         is compiled into a function call, and can run into problems with
  898.         the CALL-ARGUMENTS-LIMIT. Use REDUCE or MAPCAR instead:
  899.            (reduce #'append list-of-lists :from-end t)
  900.            (mapcan #'copy-list list-of-lists)
  901.         The second will often be more efficient (see note below about choosing
  902.         the right algorithm). Beware of calls like (apply f (mapcar ..)).
  903.  
  904.       - NTH must cdr down the list to reach the elements you are
  905.         interested in. If you don't need the structural flexibility of
  906.         lists, try using vectors and the ELT function instead.
  907.  
  908.       - Don't use quoted constants where you might later destructively
  909.         modify them. For example, instead of writing '(c d) in
  910.            (defun foo ()
  911.              (let ((var '(c d)))
  912.                ..))
  913.         write (list 'c 'd) instead. Using a quote here can lead to
  914.         unexpected results later. If you later destructively modify the 
  915.         value of var, this is self-modifying code! Some Lisp compilers
  916.         will complain about this, since they like to make constants
  917.         read-only. Modifying constants has undefined results in ANSI CL.
  918.         See also the answer to question [3-13].
  919.  
  920.         Similarly, beware of shared list structure arising from the use
  921.         of backquote. Any sublist in a backquoted expression that doesn't
  922.         contain any commas can share with the original source structure.
  923.  
  924.       - Don't proclaim unsafe optimizations, such as
  925.            (proclaim '(optimize (safety 0) (speed 3) (space 1))) 
  926.         since this yields a global effect. Instead, add the
  927.         optimizations as local declarations to small pieces of
  928.         well-tested, performance-critical code:
  929.            (defun well-tested-function ()
  930.               (declare (optimize (safety 0) (speed 3) (space 1)))
  931.              ..)
  932.         Such optimizations can remove run-time type-checking; type-checking
  933.         is necessary unless you've very carefully checked your code
  934.         and added all the appropriate type declarations.
  935.  
  936.       - Some programmers feel that you shouldn't add declarations to
  937.         code until it is fully debugged, because incorrect
  938.         declarations can be an annoying source of errors. They recommend
  939.         using CHECK-TYPE liberally instead while you are developing the code.
  940.         On the other hand, if you add declarations to tell the
  941.         compiler what you think your code is doing, the compiler can
  942.         then tell you when your assumptions are incorrect.
  943.         Declarations also make it easier for another programmer to read
  944.         your code. 
  945.  
  946.       - Don't change the compiler optimization with an OPTIMIZE
  947.         proclamation or declaration until the code is fully debugged
  948.         and profiled.  When first writing code you should say 
  949.         (declare (optimize (safety 3))) regardless of the speed setting.
  950.  
  951.       - Depending on the optimization level of the compiler, type
  952.         declarations are interpreted either as (1) a guarantee from
  953.         you that the variable is always bound to values of that type,
  954.         or (2) a desire that the compiler check that the variable is
  955.         always bound to values of that type. Use CHECK-TYPE if (2) is
  956.         your intention.
  957.  
  958.       - If you get warnings about unused variables, add IGNORE
  959.         declarations if appropriate or fix the problem. Letting such
  960.         warnings stand is a sloppy coding practice.
  961.  
  962.    To produce efficient code,
  963.  
  964.       - choose the right algorithm. For example, consider seven possible
  965.         implementations of COPY-LIST:
  966.  
  967.            (defun copy-list (list)
  968.              (let ((result nil))
  969.                (dolist (item list result)
  970.                  (setf result (append result (list item))))))
  971.  
  972.            (defun copy-list (list)
  973.              (let ((result nil))
  974.                (dolist (item list (nreverse result))
  975.                  (push item result))))
  976.  
  977.            (defun copy-list (list)
  978.              (mapcar #'identity list))
  979.  
  980.            (defun copy-list (list)
  981.              (let ((result (make-list (length list))))
  982.                (do ((original list (cdr original))
  983.                     (new result (cdr new)))
  984.                    ((null original) result)
  985.                  (setf (car new) (car original)))))
  986.  
  987.            (defun copy-list (list)
  988.              (when list
  989.                (let* ((result (list (car list)))
  990.                       (tail-ptr result))
  991.                  (dolist (item (cdr list) result)
  992.                    (setf (cdr tail-ptr) (list item))
  993.                    (setf tail-ptr (cdr tail-ptr))))))
  994.         
  995.             (defun copy-list (list)
  996.               (loop for item in list collect item))
  997.  
  998.             (defun copy-list (list)
  999.               (if (consp list) 
  1000.                   (cons (car list)
  1001.                         (copy-list (cdr list)))
  1002.                   list))
  1003.  
  1004.         The first uses APPEND to tack the elements onto the end of the list.
  1005.         Since APPEND must traverse the entire partial list at each step, this
  1006.         yields a quadratic running time for the algorithm.  The second
  1007.         implementation improves on this by iterating down the list twice; once
  1008.         to build up the list in reverse order, and the second time to reverse
  1009.         it. The efficiency of the third depends on the Lisp implementation,
  1010.         but it is usually similar to the second, as is the fourth.  The fifth
  1011.         algorithm, however, iterates down the list only once. It avoids the
  1012.         extra work by keeping a pointer (reference) to the last cons of the 
  1013.         list and RPLACDing onto the end of that. Use of the fifth algorithm 
  1014.         may yield a speedup. Note that this contradicts the earlier dictum to
  1015.         avoid destructive functions. To make more efficient code one might
  1016.         selectively introduce destructive operations in critical sections of
  1017.         code. Nevertheless, the fifth implementation may be less efficient in
  1018.         Lisps with cdr-coding, since it is more expensive to RPLACD cdr-coded
  1019.         lists. Depending on the implementation of nreverse, however,
  1020.         the fifth and second implementations may be doing the same
  1021.         amount of work. The sixth example uses the Loop macro, which usually
  1022.         expands into code similar to the third. The seventh example copies
  1023.         dotted lists, and runs in linear time. It's equivalent to the other
  1024.         linear-time examples in a lisp that is properly tail-recursive. 
  1025.  
  1026.       - use type declarations liberally in time-critical code, but
  1027.         only if you are a seasoned Lisp programmer. Appropriate type
  1028.         declarations help the compiler generate more specific and
  1029.         optimized code. It also lets the reader know what assumptions
  1030.         were made. For example, if you only use fixnum arithmetic,
  1031.         adding declarations can lead to a significant speedup. If you
  1032.         are a novice Lisp programmer, you should use type declarations
  1033.         sparingly, as there may be no checking to see if the
  1034.         declarations are correct. Wrong declarations can lead to errors
  1035.         in otherwise correct code, and can limit the reuse of code
  1036.         in other contexts. Depending on the Lisp compiler, it may also
  1037.         be necessary to declare the type of results using THE, since
  1038.         some compilers don't deduce the result type from the inputs.
  1039.  
  1040.       - check the code produced by the compiler by using the
  1041.         disassemble function
  1042.  
  1043. ----------------------------------------------------------------
  1044. [1-3] Where can I learn about implementing Lisp interpreters and compilers?
  1045.  
  1046. Books about Lisp implementation include:
  1047.  
  1048.    1. John Allen
  1049.       "Anatomy of Lisp"
  1050.       McGraw-Hill, 1978. 446 pages. ISBN 0-07-001115-X
  1051.  
  1052.    2. Samuel Kamin
  1053.       "Programming Languages, An Interpreter-Based Approach"
  1054.       Addison-Wesley. ISBN 0-201-06824-9
  1055.            Includes sources to several interpreters for Lisp-like
  1056.            languages, and a pointer to sources via anonymous ftp.
  1057.  
  1058.    3. Sharam Hekmatpour
  1059.       "Lisp: A Portable Implementation"
  1060.       Prentice Hall, 1985. ISBN 0-13-537490-X.
  1061.            Describes a portable implementation of a small dynamic
  1062.            Lisp interpreter (including C source code). 
  1063.  
  1064.    4. Peter Henderson
  1065.       "Functional Programming: Application and Implementation"
  1066.       Prentice-Hall (Englewood Cliffs, NJ), 1980. 355 pages.
  1067.  
  1068.    5. Peter M. Kogge
  1069.       "The Architecture of Symbolic Computers"
  1070.       McGraw-Hill, 1991. ISBN 0-07-035596-7.
  1071.            Includes sections on memory management, the SECD and
  1072.            Warren Abstract Machines, and overviews of the various
  1073.            Lisp Machine architectures.
  1074.    
  1075.    6. Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes
  1076.       "Essentials of Programming Languages"
  1077.       MIT Press, 1992, 536 pages. ISBN 0-262-06145-7.
  1078.            Teaches fundamental concepts of programming language
  1079.            design by using small interpreters as examples. Covers
  1080.            most of the features of Scheme. Includes a discussion
  1081.            of parameter passing techniques, object oriented languages,
  1082.            and techniques for transforming interpreters to allow
  1083.            their implementation in terms of any low-level language.
  1084.            Also discusses scanners, parsers, and the derivation of
  1085.            a compiler and virtual machine from an interpreter.
  1086.            Source files available by anonymous ftp from cs.indiana.edu
  1087.            in the directory /pub/eopl (129.79.254.191).
  1088.  
  1089.    7. Also see the proceedings of the biannual ACM Lisp and
  1090.       Functional Programming conferences, and the implementation
  1091.       notes for CMU Common Lisp.
  1092. ----------------------------------------------------------------
  1093. [1-4]  What does CLOS, PCL, X3J13, CAR, CDR, ... mean? 
  1094.  
  1095. Glossary of acronyms:
  1096.    CAR             Originally meant "Contents of Address portion of Register",
  1097.                    which is what CAR actually did on the IBM 704.
  1098.    CDR             Originally meant "Contents of Decrement portion of 
  1099.                    Register", which is what CDR actually did
  1100.                    on the IBM 704. Pronounced "Cudder".
  1101.    LISP            Originally from "LISt Processing"
  1102.    GUI             Graphical User Interface
  1103.    CLOS            Common Lisp Object System. The object oriented
  1104.                    programming standard for Common Lisp. Based on
  1105.                    Symbolics FLAVORS and Xerox LOOPS, among others.
  1106.                    Pronounced either as "See-Loss" or "Closs". See also PCL.
  1107.    PCL             Portable Common Loops. A portable CLOS implementation.
  1108.                    Available by anonymous ftp from parcftp.xerox.com:pcl/.
  1109.    LOOPS           Lisp Object Oriented Programming System. A predecessor
  1110.                    to CLOS on Xerox Lisp machines.
  1111.    X3J13           Subcommittee of the ANSI committee X3 which is
  1112.                    working on the ANSI Standardization of Common Lisp.
  1113.    ANSI            American National Standards Institute
  1114.    CL              Common Lisp
  1115.    SC22/WG16       The full name is ISO/IEC JTC 1/SC 22/WG 16. It stands
  1116.                    for International Organization for
  1117.                    Standardization/International Electronics(?)  
  1118.                    Congress(?) Joint Technical Committee 1, Subcommittee 22,
  1119.                    Working Group 16.  This long-winded name is the ISO
  1120.                    working group working on an international Lisp standard,
  1121.                    (i.e., the ISO analogue to X3J13).
  1122.    CLtL1           First edition of Guy Steele's book, 
  1123.                    "Common Lisp the Language". 
  1124.    CLtL2           Second edition of Guy Steele's book,
  1125.                    "Common Lisp the Language". 
  1126.  
  1127.    SICP            Abelson and Sussman's book "Structure and
  1128.                    Interpretation of Computer Programs".
  1129.    SCOOPS          An experimental object-oriented programming
  1130.                    language for Scheme.
  1131.    R3RS            Revised^3 Report on the Algorithmic Language Scheme.
  1132.    R4RS            Revised^4 Report on the Algorithmic Language Scheme.
  1133. ----------------------------------------------------------------
  1134. [1-5]   Where can I get a copy of the draft ANSI standard for Common Lisp?
  1135.  
  1136. The draft proposed American National Standard for Common Lisp is under
  1137. public review until November 23, 1992. 
  1138.  
  1139. Hard copies of the draft may be purchased from Global Engineering
  1140. Documents, Inc., 2805 McGaw Avenue, Irvine, CA  92714, 1-800-854-7179,
  1141. 714-261-1455 for a single copy price of $80 ($104 international).
  1142. Copies of the TeX sources and Unix-compressed DVI files may be
  1143. obtained by anonymous FTP from parcftp.xerox.com in the directory
  1144. /pub/cl/document/*. The file Reviewer-Notes.text should be read before
  1145. ftp'ing the other files.
  1146.  
  1147. There is no mechanism for submitting Public Review comments by e-mail.
  1148. Comments on the draft must be submitted in hard copy format BOTH to X3
  1149. Secretariat, Attn: Lynn Barra, 1250 Eye Street NW, Suite 200,
  1150. Washington, DC 20005-3922 AND to American National Standards Institute,
  1151. Attn: BSR Center, 11 West 42nd St. 13th Floor, New York, NY 10036.
  1152.  
  1153. ----------------------------------------------------------------
  1154. [1-6]   Lisp Job Postings
  1155.  
  1156. The LISP-JOBS mailing list exists to help programmers find Lisp
  1157. programming positions, and to help companies with Lisp programming
  1158. positions find capable Lisp programmers. (Lisp here means Lisp-like
  1159. languages, including Scheme.)
  1160.  
  1161. Material appropriate for the list includes Lisp job announcements and
  1162. resumes from Lisp programmers (which should be sent only once) should
  1163. be sent to lisp-jobs@amc.com.  Administrative requests (e.g., to be
  1164. added to the list) should be sent to lisp-jobs-request@amc.com.
  1165.  
  1166. ----------------------------------------------------------------
  1167.      
  1168. ;;; ********************************
  1169. ;;; Change Log *********************
  1170. ;;; ********************************
  1171. ;;; Date      Who     Ver   Reason
  1172. ;;; ------------------------------------------------------------
  1173. ;;;  7-FEB-92 mk      1.0   Initial release.
  1174. ;;; 10-FEB-92 mk      1.1   Pre-release corrections and additions.
  1175. ;;; 10-FEB-92 mk      1.11  Minor changes from Arun Welch, Mitch Marks, 
  1176. ;;;                         Mike Meyer, Matthias Felleisen, and John Gateley.
  1177. ;;; 11-FEB-92 mk      1.12  Corrections by John Carroll, Jason Trenouth, Joel
  1178. ;;;                         Riedesel, David Neves, Lawrence Mayka and
  1179. ;;;                         Bruce Miller.
  1180. ;;; 13-FEB-92 mk      1.13  Renumbering. Split into 3 files. Some more FAQs.
  1181. ;;; 23-MAR-92 mk      1.14  Updated various FTP entries, bug in EXPLODE.
  1182. ;;;                         Updated harlequin entry.
  1183. ;;; 25-MAR-92 mk      1.15  Added question [2-18]: saving data and CLOS
  1184. ;;;                         instances to disk for later retrieval.
  1185. ;;;  1-MAY-92 mk      1.17  Added entry for Feel to question [1-5]. Updated CMU
  1186. ;;;                         ftp machines to point to ftp.cs.cmu.edu. Fixed CMU
  1187. ;;;                         CL entry to be approximately version independent.
  1188. ;;;                         Revised entry on Garnet. uunet.uu.net -> ftp.uu.net
  1189. ;;; 12-MAY-92 mk      1.18  Split questions 1-5, 1-6, and 1-7 into part 4,
  1190. ;;;                         which is now cross-posted to comp.lang.scheme, and
  1191. ;;;                         questions 1-8, 2-3, 2-9 and 2-18 into part 5 which
  1192. ;;;                         is now cross-posted to comp.lang.clos.
  1193. ;;;                         Added detail to Norvig entry in 1-1.
  1194. ;;;                         Updated entries for several Lisp implementations.
  1195. ;;; 26-MAY-92 mk      1.19  Changed 5-2 on the basis of comments by Jeff Greif.
  1196. ;;; 29-MAY-92 mk      1.20  Added question [2-17] about lisp sockets.
  1197. ;;; 16-JUN-92 mk      1.21  Moved the question about object oriented
  1198. ;;;                         programming references to part 5 of the FAQ.
  1199. ;;;                         Entry on Dylan. Addition to MIT Scheme entry
  1200. ;;;                         regarding Schematik.
  1201. ;;; 22-JUN-92 mk            Updated SOAR entry.
  1202. ;;; 24-JUN-92 mk            Fixed MCL entry to note that CLIM is available 
  1203. ;;;                         from ILA, not via Apple.
  1204. ;;; 25-JUN-92 mk      1.22  Added question [2-18].
  1205. ;;; 17-JUL-92 mk            Added entry on PSD (Portable Scheme Debugger).
  1206. ;;; 20-JUL-92 mk            Updated entry on T3.1
  1207. ;;; 30-JUL-92 mk            Added entry on XIT to question 2-2.
  1208. ;;;  3-AUG-92 mk            Updated PC-Scheme entry (bought by Ibuki).
  1209. ;;;  6-AUG-92 mk      1.23  Merged in Jeff Dalton's pitfalls list.
  1210. ;;; 19-AUG-92 mk            Added entry on FOCL. Move three questions from 
  1211. ;;;                         part 2 to part 3, to keep part 2 under 64k.
  1212. ;;; 26-AUG-92 mk            Added some items from Hallvard Tretteberg's
  1213. ;;;                         Lisp style guide.
  1214. ;;; 31-AUG-92 mk      1.24  Updated entries for CMU CL and SIOD.
  1215. ;;;  8-SEP-92 mk            Added entry on VSCM to part 4. Added entry on
  1216. ;;;                         Pixie Scheme, Help, and Le-Lisp.
  1217. ;;; 14-SEP-92 mk            Fixed Symbolics entry. Added entry on CLIM-library.
  1218. ;;; 15-SEP-92 mk            Updated MIT C-Scheme entry.
  1219. ;;; 17-SEP-92 mk            Added entry on Lisp-Jobs. Fixed Le-Lisp entry.
  1220. ;;;                         Added 3-15.
  1221. ;;; 23-SEP-92 mk            Added entry on COLAB to ftp resources.
  1222. ;;;                         Added entry on WCL to Part 4.
  1223. ;;; 30-SEP-92 mk            Added entry on Dr. Dobb's lisp-style C extensions.
  1224. ;;;                         Updated entry on Friedman/Wand/Haynes' book.
  1225. ;;;  9-OCT-92 mk      1.25  Updated Chez Scheme entry.
  1226. ;;;                         Added entry on extracting the function name from
  1227. ;;;                         the function object, provided by Kerry Koitzsch.
  1228. ;;; 14-OCT-92 mk      1.26  Split off the ftp resources question from Part 2
  1229. ;;;                         into its own file, now labels Part 6.
  1230. ;;;                         Broke up the question into smaller pieces
  1231. ;;;                         and reorganized it too. Reorganized Part 4.
  1232. ;;; 20-OCT-92 mk            Added description of Koschmann text,
  1233. ;;;                         thanks to L. Mayka.
  1234. ;;; 27-OCT-92 mk      1.27  Added question 6-6 about formatting code in LaTeX.
  1235. ;;;  3-NOV-92 mk            Added comment on file modularization to 1-2.
  1236. ;;;                         Added note on the CLOS code repository to
  1237. ;;;                         6-1.
  1238. ;;;  5-NOV-92 mk            Added info on Lucid benchmark programs in the 
  1239. ;;;                         goodies/ directory. Also the Lucid
  1240. ;;;                         wizards.doc file.
  1241. ;;; 11-NOV-92 mk    Added entry on Karlsruhe CLISP to 4-0.
  1242. ;;; 13-NOV-92 mk    Added entry on ARS MAGNA to part 6, subsection Planning
  1243. ;;;                 Testbeds.
  1244. ;;; 17-NOV-92 mk    Added entry on GECO and GAL to 6-3.
  1245. ;;; 17-NOV-92 mk    Updated prices in Allegro CL entry.
  1246. ;;; 24-NOV-92 mk    Added entry on the automatic memoization facility
  1247. ;;;                 to part 6. 
  1248. ;;; ------------------------------------------------------------
  1249.  
  1250. ;;; *EOF*
  1251.